home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / pack / xpk25dev.lha / include / libraries / xpk.h next >
C/C++ Source or Header  |  1992-11-04  |  15KB  |  396 lines

  1. /*
  2. **    $Filename: xpk.h $
  3. **    $Release: 0.9 $
  4. **
  5. **
  6. **
  7. **    (C) Copyright 1991 U. Dominik Mueller, Bryan Ford, Christian Schneider
  8. **        All Rights Reserved
  9. */
  10.  
  11. #ifndef LIBRARIES_XPK_H
  12. #define LIBRARIES_XPK_H
  13.  
  14. #ifndef EXEC_TYPES_H
  15. #include <exec/types.h>
  16. #endif
  17.  
  18. #ifndef EXEC_NODES_H
  19. #include <exec/nodes.h>
  20. #endif
  21.  
  22. #if INCLUDE_VERSION >= 36
  23.  
  24. #ifndef UTILITY_TAGITEM_H
  25. #include <utility/tagitem.h>
  26. #endif
  27.  
  28. #ifndef UTILITY_HOOKS_H
  29. #include <utility/hooks.h>
  30. #endif
  31.  
  32. #else
  33.  
  34. typedef ULONG    Tag; /* Extracted (without permission) from utility/tagitem.h */
  35. struct TagItem    {
  36.     Tag        ti_Tag;
  37.     ULONG    ti_Data;
  38. };
  39.  
  40. #define TAG_DONE   (0L)     /* terminates array of TagItems. ti_Data unused */
  41. #define TAG_IGNORE (1L)     /* ignore this item, not end of array           */
  42. #define TAG_USER   (1L<<31) /* differentiates user tags from system tags    */
  43.  
  44. struct Hook    {               /* Likewise, but from utility/hooks.h */
  45.     struct MinNode    h_MinNode;
  46.     ULONG        (*h_Entry)();    /* assembler entry point    */
  47.     ULONG        (*h_SubEntry)();/* often HLL entry point    */
  48.     VOID        *h_Data;    /* owner specific        */
  49. };
  50.  
  51. #endif
  52.  
  53. typedef struct TagItem  TAGS;
  54. typedef struct Hook *   HOOK;
  55.  
  56. #define XPKNAME "xpkmaster.library"
  57.  
  58. /*****************************************************************************
  59.  *
  60.  *
  61.  *      The packing/unpacking tags
  62.  *
  63.  */
  64.  
  65. #define XPK_TagBase    (TAG_USER + 'X'*256 + 'P')
  66. #define XTAG(a) (XPK_TagBase+a)
  67.  
  68. /* Caller must supply ONE of these to tell Xpk#?ackFile where to get data from */
  69. #define XPK_InName      XTAG(0x01)    /* Process an entire named file */
  70. #define XPK_InFH      XTAG(0x02)    /* File handle - start from current position */
  71.                     /* If packing partial file, must also supply InLen */
  72. #define XPK_InBuf      XTAG(0x03)    /* Single unblocked memory buffer */
  73.                     /* Must also supply InLen */
  74. #define XPK_InHook      XTAG(0x04)    /* Call custom Hook to read data */
  75.                     /* If packing, must also supply InLen */
  76.                     /* If unpacking, InLen required only for PPDecrunch */
  77.  
  78. /* Caller must supply ONE of these to tell Xpk#?ackFile where to send data to */
  79. #define XPK_OutName      XTAG(0x10)    /* Write (or overwrite) this data file */
  80. #define XPK_OutFH      XTAG(0x11)    /* File handle - write from current position on */
  81. #define XPK_OutBuf      XTAG(0x12)    /* Unblocked buffer - must also supply OutBufLen */
  82. #define XPK_GetOutBuf      XTAG(0x13)    /* Master allocates OutBuf - ti_Data points to buf ptr */
  83. #define XPK_OutHook      XTAG(0x14)    /* Callback Hook to get output buffers */
  84.  
  85. /* Other tags for Pack/Unpack */
  86. #define XPK_InLen      XTAG(0x20)    /* Length of data in input buffer  */
  87. #define XPK_OutBufLen      XTAG(0x21)    /* Length of output buffer         */
  88. #define XPK_GetOutLen      XTAG(0x22)    /* ti_Data points to long to receive OutLen    */
  89. #define XPK_GetOutBufLen  XTAG(0x23)    /* ti_Data points to long to receive OutBufLen */
  90. #define XPK_Password      XTAG(0x24)    /* Password for de/encoding        */
  91. #define XPK_GetError      XTAG(0x25)    /* ti_Data points to buffer for error message  */
  92. #define XPK_OutMemType      XTAG(0x26)    /* Memory type for output buffer   */
  93. #define XPK_PassThru      XTAG(0x27)    /* Bool: Pass through unrecognized formats on unpack */
  94. #define XPK_StepDown      XTAG(0x28)    /* Bool: Step down pack method if necessary    */
  95. #define XPK_ChunkHook      XTAG(0x29)    /* Call this Hook between chunks   */
  96. #define XPK_PackMethod      XTAG(0x2a)    /* Do a FindMethod before packing  */
  97. #define XPK_ChunkSize      XTAG(0x2b)    /* Chunk size to try to pack with  */
  98. #define XPK_PackMode      XTAG(0x2c)    /* Packing mode for sublib to use  */
  99. #define XPK_NoClobber      XTAG(0x2d)    /* Don't overwrite existing files  */
  100. #define XPK_Ignore      XTAG(0x2e)    /* Skip this tag                   */
  101. #define XPK_TaskPri      XTAG(0x2f)    /* Change priority for (un)packing */
  102. #define XPK_FileName      XTAG(0x30)    /* File name for progress report   */
  103. #define XPK_ShortError      XTAG(0x31)    /* Output short error messages     */
  104. #define XPK_PackersQuery  XTAG(0x32)    /* Query available packers         */
  105. #define XPK_PackerQuery      XTAG(0x33)    /* Query properties of a packer    */
  106. #define XPK_ModeQuery      XTAG(0x34)    /* Query properties of packmode    */
  107. #define XPK_LossyOK          XTAG(0x35)    /* Lossy packing permitted? def.=no*/
  108.  
  109.  
  110. #define XPK_FindMethod XPK_PackMethod    /* Compatibility */
  111.  
  112. #define XPK_MARGIN    256    /* Safety margin for output buffer    */
  113.  
  114.  
  115.  
  116.  
  117. /*****************************************************************************
  118.  *
  119.  *
  120.  *     The hook function interface
  121.  *
  122.  */
  123.  
  124. /* Message passed to InHook and OutHook as the ParamPacket */
  125. typedef struct XpkIOMsg {
  126.     ULONG Type        ; /* Read/Write/Alloc/Free/Abort    */
  127.     APTR  Ptr        ; /* The mem area to read from/write to */
  128.     LONG  Size        ; /* The size of the read/write        */
  129.     LONG  IOError        ; /* The IoErr() that occurred        */
  130.     LONG  Reserved        ; /* Reserved for future use        */
  131.     LONG  Private1        ; /* Hook specific, will be set to 0 by */
  132.     LONG  Private2        ; /* master library before first use    */
  133.     LONG  Private3        ;
  134.     LONG  Private4        ;
  135. } XIOMSG;
  136.  
  137. /* The values for XpkIoMsg->Type */
  138. #define XIO_READ    1
  139. #define XIO_WRITE   2
  140. #define XIO_FREE    3
  141. #define XIO_ABORT   4
  142. #define XIO_GETBUF  5
  143. #define XIO_SEEK    6
  144. #define XIO_TOTSIZE 7
  145.  
  146.  
  147.  
  148.  
  149.  
  150. /*****************************************************************************
  151.  *
  152.  *
  153.  *      The progress report interface
  154.  *
  155.  */
  156.  
  157. /* Passed to ChunkHook as the ParamPacket */
  158. typedef struct XpkProgress {
  159.     LONG    Type        ; /* Type of report: start/cont/end/abort    */
  160.     STRPTR    PackerName    ; /* Brief name of packer being used         */
  161.     STRPTR    PackerLongName    ; /* Descriptive name of packer being used     */
  162.     STRPTR    Activity    ; /* Packing/unpacking message            */
  163.     STRPTR    FileName    ; /* Name of file being processed, if available */
  164.     LONG    CCur        ; /* Amount of packed data already processed    */
  165.     LONG    UCur        ; /* Amount of unpacked data already processed     */
  166.     LONG    ULen        ; /* Amount of unpacked data in file        */
  167.     LONG    CF        ; /* Compression factor so far            */
  168.     LONG    Done        ; /* Percentage done already            */
  169.     LONG    Speed        ; /* Bytes per second, from beginning of stream */
  170.     LONG    Reserved[8]    ; /* For future use                */
  171. } XPROG;
  172. #define XPKPROG_START    1
  173. #define XPKPROG_MID    2
  174. #define XPKPROG_END    3
  175.  
  176.  
  177.  
  178.  
  179.  
  180. /*****************************************************************************
  181.  *
  182.  *
  183.  *       The file info block
  184.  *
  185.  */
  186. struct XpkFib {
  187.     LONG    Type        ; /* Unpacked, packed, archive?   */
  188.     LONG    ULen        ; /* Uncompressed length          */
  189.     LONG    CLen        ; /* Compressed length            */
  190.     LONG    NLen        ; /* Next chunk len               */
  191.     LONG    UCur        ; /* Uncompressed bytes so far    */
  192.     LONG    CCur        ; /* Compressed bytes so far      */
  193.     LONG    ID        ; /* 4 letter ID of packer        */
  194.     UBYTE    Packer[6]    ; /* 4 letter name of packer      */
  195.     WORD    SubVersion    ; /* Required sublib version      */
  196.     WORD    MasVersion    ; /* Required masterlib version   */
  197.     LONG    Flags        ; /* Password?                    */
  198.     UBYTE    Head[16]    ; /* First 16 bytes of orig. file */
  199.     LONG    Ratio        ; /* Compression ratio            */
  200.     LONG    Reserved[8]    ; /* For future use               */
  201. };
  202. typedef struct XpkFib XFIB;
  203.  
  204. #define XPKTYPE_UNPACKED 0        /* Not packed                   */
  205. #define XPKTYPE_PACKED   1        /* Packed file                  */
  206. #define XPKTYPE_ARCHIVE  2        /* Archive                      */
  207.  
  208. #define XPKFLAGS_PASSWORD 1       /* Password needed              */
  209. #define XPKFLAGS_NOSEEK   2       /* Chunks are dependent         */
  210. #define XPKFLAGS_NONSTD   4       /* Nonstandard file format      */
  211.  
  212.  
  213.  
  214.  
  215.  
  216. /*****************************************************************************
  217.  *
  218.  *
  219.  *       The error messages
  220.  *
  221.  */
  222.  
  223. #define XPKERR_OK      0
  224. #define XPKERR_NOFUNC       -1    /* This function not implemented    */
  225. #define XPKERR_NOFILES       -2    /* No files allowed for this function    */
  226. #define XPKERR_IOERRIN       -3    /* Input error happened, look at Result2*/
  227. #define XPKERR_IOERROUT       -4    /* Output error happened,look at Result2*/
  228. #define XPKERR_CHECKSUM       -5    /* Check sum test failed        */
  229. #define XPKERR_VERSION       -6    /* Packed file's version newer than lib */
  230. #define XPKERR_NOMEM       -7    /* Out of memory            */
  231. #define XPKERR_LIBINUSE       -8    /* For not-reentrant libraries        */
  232. #define XPKERR_WRONGFORM   -9    /* Was not packed with this library    */
  233. #define XPKERR_SMALLBUF       -10    /* Output buffer too small        */
  234. #define XPKERR_LARGEBUF       -11    /* Input buffer too large        */
  235. #define XPKERR_WRONGMODE   -12    /* This packing mode not supported    */
  236. #define XPKERR_NEEDPASSWD  -13    /* Password needed for decoding        */
  237. #define XPKERR_CORRUPTPKD  -14    /* Packed file is corrupt        */
  238. #define XPKERR_MISSINGLIB  -15    /* Required library is missing        */
  239. #define XPKERR_BADPARAMS   -16    /* Caller's TagList was screwed up    */
  240. #define XPKERR_EXPANSION   -17    /* Would have caused data expansion    */
  241. #define XPKERR_NOMETHOD    -18    /* Can't find requested method        */
  242. #define XPKERR_ABORTED     -19    /* Operation aborted by user        */
  243. #define XPKERR_TRUNCATED   -20    /* Input file is truncated        */
  244. #define XPKERR_WRONGCPU    -21    /* Better CPU required for this library    */
  245. #define XPKERR_PACKED      -22    /* Data are already XPacked        */
  246. #define XPKERR_NOTPACKED   -23    /* Data not packed            */
  247. #define XPKERR_FILEEXISTS  -24    /* File already exists            */
  248. #define XPKERR_OLDMASTLIB  -25    /* Master library too old        */
  249. #define XPKERR_OLDSUBLIB   -26    /* Sub library too old            */
  250. #define XPKERR_NOCRYPT     -27    /* Cannot encrypt            */
  251. #define XPKERR_NOINFO      -28    /* Can't get info on that packer    */
  252. #define XPKERR_LOSSY       -29    /* This compression method is lossy    */
  253. #define XPKERR_NOHARDWARE  -30    /* Compression hardware required    */
  254. #define XPKERR_BADHARDWARE -31    /* Compression hardware failed        */
  255. #define XPKERR_WRONGPW     -32    /* Password was wrong            */
  256.  
  257. #define XPKERRMSGSIZE    80    /* Maximum size of an error message    */
  258.  
  259.  
  260.  
  261.  
  262.  
  263. /*****************************************************************************
  264.  *
  265.  *
  266.  *     The XpkQuery() call
  267.  *
  268.  */
  269.  
  270. typedef struct XpkPackerInfo {
  271.     BYTE    Name[24]        ; /* Brief name of the packer          */
  272.     BYTE    LongName[32]    ; /* Full name of the packer           */
  273.     BYTE    Description[80] ; /* One line description of packer    */
  274.     LONG    Flags           ; /* Defined below                     */
  275.     LONG    MaxChunk        ; /* Max input chunk size for packing  */
  276.     LONG    DefChunk        ; /* Default packing chunk size        */
  277.     UWORD   DefMode         ; /* Default mode on 0..100 scale      */
  278. } XPINFO;
  279.  
  280. /* Defines for Flags */
  281. #define XPKIF_PK_CHUNK    0x00000001 /* Library supplies chunk packing       */
  282. #define XPKIF_PK_STREAM   0x00000002 /* Library supplies stream packing      */
  283. #define XPKIF_PK_ARCHIVE  0x00000004 /* Library supplies archive packing     */
  284. #define XPKIF_UP_CHUNK    0x00000008 /* Library supplies chunk unpacking     */
  285. #define XPKIF_UP_STREAM   0x00000010 /* Library supplies stream unpacking    */
  286. #define XPKIF_UP_ARCHIVE  0x00000020 /* Library supplies archive unpacking   */
  287. #define XPKIF_HOOKIO      0x00000080 /* Uses full Hook I/O                   */
  288. #define XPKIF_CHECKING    0x00000400 /* Does its own data checking           */
  289. #define XPKIF_PREREADHDR  0x00000800 /* Unpacker pre-reads the next chunkhdr */
  290. #define XPKIF_ENCRYPTION  0x00002000 /* Sub library supports encryption      */
  291. #define XPKIF_NEEDPASSWD  0x00004000 /* Sub library requires encryption      */
  292. #define XPKIF_MODES       0x00008000 /* Sub library has different modes      */
  293. #define XPKIF_LOSSY       0x00010000 /* Sub library does lossy compression   */
  294.  
  295.  
  296. typedef struct XpkMode {
  297.     struct XpkMode *Next   ; /* Chain to next descriptor for ModeDesc list*/
  298.     ULONG   Upto           ; /* Maximum efficiency handled by this mode   */
  299.     ULONG   Flags          ; /* Defined below                             */
  300.     ULONG   PackMemory     ; /* Extra memory required during packing      */
  301.     ULONG   UnpackMemory   ; /* Extra memory during unpacking             */
  302.     ULONG   PackSpeed      ; /* Approx packing speed in K per second      */
  303.     ULONG   UnpackSpeed    ; /* Approx unpacking speed in K per second    */
  304.     UWORD   Ratio          ; /* CF in 0.1% for AmigaVision executable     */
  305.     UWORD   ChunkSize      ; /* Desired chunk size in K (!!) for this mode*/
  306.     BYTE    Description[10]; /* 7 character mode description              */
  307. } XMINFO;
  308.  
  309. /* Defines for XpkMode.Flags */
  310. #define XPKMF_A3000SPEED 0x00000001    /* Timings on A3000/25               */
  311. #define XPKMF_PK_NOCPU   0x00000002    /* Packing not heavily CPU dependent */
  312. #define XPKMF_UP_NOCPU   0x00000004    /* Unpacking... (i.e. hardware modes)*/
  313.  
  314. #define MAXPACKERS 100
  315.  
  316. typedef struct XpkPackerList {
  317.     ULONG    NumPackers;
  318.     BYTE    Packer[MAXPACKERS][6];
  319. } XPLIST;
  320.  
  321.  
  322.  
  323. /*****************************************************************************
  324.  *
  325.  *
  326.  *     The XpkOpen() type calls
  327.  *
  328.  */
  329.  
  330. #define XPKLEN_ONECHUNK 0x7fffffff
  331. #define XpkFH XpkFib
  332. typedef struct XpkFib XFH;
  333.  
  334.  
  335. /*****************************************************************************
  336.  *
  337.  *
  338.  *      The library vectors
  339.  *
  340.  */
  341.  
  342. #define REG  register
  343. #define _a0  register __a0
  344. #define _a1  register __a1
  345. #define _a2  register __a2
  346. #define _a4  register __a4
  347. #define _d0  register __d0
  348. #define _d1  register __d1
  349.  
  350. #ifndef NO_XPK_PROTOS
  351.  
  352. LONG XpkExamine      ( XFIB *fib, TAGS *tags);
  353. LONG XpkPack         ( TAGS *tags );
  354. LONG XpkUnpack       ( TAGS *tags );
  355. LONG XpkOpen         ( XFH **xfh, TAGS  *tags );
  356. LONG XpkRead         ( XFH  *xfh, UBYTE *buf, LONG len  );
  357. LONG XpkWrite        ( XFH  *xfh, UBYTE *buf, LONG ulen );
  358. LONG XpkSeek         ( XFH  *xfh, LONG  dist, LONG mode );
  359. LONG XpkClose        ( XFH  *xfh  );
  360. LONG XpkQuery        ( TAGS *tags );
  361. LONG XpkExamineTags  ( XFIB *fib, ULONG, ... );
  362. LONG XpkPackTags     ( ULONG, ... );
  363. LONG XpkUnpackTags   ( ULONG, ... );
  364. LONG XpkQueryTags    ( ULONG, ... );
  365. LONG XpkOpenTags     ( XFH **xfh, ULONG, ... );
  366.  
  367. #ifndef NO_XPK_PRAGMAS
  368. #ifdef LATTICE
  369. # pragma libcall XpkBase XpkExamine 24  9802
  370. # pragma libcall XpkBase XpkPack    2A   801
  371. # pragma libcall XpkBase XpkUnpack  30   801
  372. # pragma libcall XpkBase XpkOpen    36  9802
  373. # pragma libcall XpkBase XpkRead    3C 09803
  374. # pragma libcall XpkBase XpkWrite   42 09803
  375. # pragma libcall XpkBase XpkSeek    48 10803
  376. # pragma libcall XpkBase XpkClose   4E   801
  377. # pragma libcall XpkBase XpkQuery   54   801
  378. #endif
  379.  
  380. #ifdef AZTEC_C
  381. # pragma amicall(XpkBase, 0x24, XpkExamine(a0,a1))
  382. # pragma amicall(XpkBase, 0x2a, XpkPack(a0))
  383. # pragma amicall(XpkBase, 0x30, XpkUnpack(a0))
  384. # pragma amicall(XpkBase, 0x36, XpkOpen(a0,a1))
  385. # pragma amicall(XpkBase, 0x3c, XpkRead(a0,a1,d0))
  386. # pragma amicall(XpkBase, 0x42, XpkWrite(a0,a1,d0))
  387. # pragma amicall(XpkBase, 0x48, XpkSeek(a0,d0,d1))
  388. # pragma amicall(XpkBase, 0x4e, XpkClose(a0))
  389. # pragma amicall(XpkBase, 0x54, XpkQuery(a0))
  390. #endif
  391.  
  392. #endif
  393. #endif
  394.  
  395. #endif /* LIBRARIES_XPK_H */
  396.